# Maintainer: BlackIkeEagle <ike DOT devolder AT gmail DOT com>
# Contributor: Kevin Piche <kevin@archlinux.org>
# Contributor: Tom Newsom <Jeepster@gmx.co.uk>
# vim: set ft=sh:

pkgname=fwbuilder
pkgver=5.3.7
pkgrel=12
pkgdesc="Object-oriented GUI and set of compilers for various firewall platforms"
url="https://github.com/fwbuilder"
arch=('loong64' 'x86_64')
license=('GPL')
depends=('libxslt' 'net-snmp' 'qt5-base' 'desktop-file-utils' 'hicolor-icon-theme' 'shared-mime-info')
conflicts=('libfwbuilder')
source=(
    "$pkgname-$pkgver.tar.gz::https://github.com/$pkgname/$pkgname/archive/v$pkgver.tar.gz"
    "$pkgname-c++17.patch::https://github.com/fwbuilder/fwbuilder/commit/ed4db20ec6ca.patch"
    'fwbuilder.xml'
)
sha512sums=('d6504ddab17e80cb332f005b6bbb16c15a7b4735361733f0e0437cb94059a5c9039e563be6e0e8d328954db2416b2c0bdbb8afa36cd946f61e7c7edaee47453b'
            'ec3f157eeed6cb2fb9b0b333518cef63e48b409ed87784ae5839676a7f09d880ec70609c64a5c54ff064540c45162abfc0de82fc0845548560854cd1e2b22df9'
            'a7b8847b3d053435290fd41fcfa534c368e10f781d990709302c2511065b451b5b9d341509efabccc241d92252cdff052a2dc04cbf18024dfe386c99d0a25505')

prepare() {
    cd "$pkgname-$pkgver"
    find -name "qmake.inc.in" -exec sed -e 's/\/usr\/include//g' -i {} \;
    sed -i '/FLAGS=/i FLAGS=.' runqmake.sh

    # https://github.com/fwbuilder/fwbuilder/pull/45
    patch -Np1 -i ../$pkgname-c++17.patch
}

build() {
    cd "$pkgname-$pkgver"
    ./autogen.sh --prefix=/usr
    make
}

package() {
    cd "$pkgname-$pkgver"
    make INSTALL_ROOT="${pkgdir}" install
    echo "MimeType=text/x-xml-fwbuilder;" >> "$pkgdir/usr/share/applications/${pkgname}.desktop"
    install -Dm644 "$srcdir/fwbuilder.xml" "$pkgdir/usr/share/mime/packages/fwbuilder.xml"
}
